package com.uchengwang.ui.cm_ui.uu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.uchengwang.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by U城网 on 2017/10/12.
 * UU右上角加号
 */

public class ChooseItemAdapter extends BaseAdapter{
    private List<String> stringList ;
    private Context context;

    public ChooseItemAdapter(Context context, List<String> stringList){
        this.context = context;
        this.stringList = stringList;
    }

    @Override
    public int getCount() {
        return stringList.size();
    }

    @Override
    public Object getItem(int i) {
        return stringList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ChooseVH holder = null;
        if (view == null){
            holder = new ChooseVH();
            view = LayoutInflater.from(context).inflate(R.layout.layout_item_choose, null, false);
            holder.choose_text = (TextView) view.findViewById(R.id.choose_text);

            view.setTag(holder);
            AutoUtils.autoSize(view);
        }else {
            holder = (ChooseVH) view.getTag();
        }

        holder.choose_text.setText(stringList.get(i));

        return view;
    }

    private class ChooseVH{
        private TextView choose_text;
    }
}
